<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 222 666 3 本轮tick结束 111 777  6 
            function wait() {
                return new Promise((resolve) => {
                    setTimeout(() => {   // h1 
                        console.log(111)   
                        const p =  new Promise(resolve => {
                            console.log(777)
                            resolve(6)
                        })
                        p.then(res => {
                            console.log(res)
                        })

                    }, 1000)

                    console.log(222)  

                    resolve(666)
                })
            }
            wait().then((res) => { // w1
                console.log(res)
                console.log(3)
            })
    </script>
</body>
</html>